package com.wus.system.controller;

import com.wus.common.core.domain.base.Result;
import com.wus.system.entity.SysOperLog;
import com.wus.system.request.OperLogReq;
import com.wus.system.service.ISysOperLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 操作日志控制类
 * @Author: wus
 * @Date: 2025/1/22 15:34
 */
@Tag(name = "操作日志控制类")
@Validated
@RequiredArgsConstructor
@RequestMapping("/system/operLog")
@RestController
public class SysOperLogController {

    private final ISysOperLogService operLogService;

    @Operation(summary = "列表查询")
    @GetMapping("/list")
    public Result<List<SysOperLog>> listLog() {
        return Result.ok(operLogService.listLog());
    }

    /**
     * 内部日志操作添加-feign服务接口
     * ps：后续其他微服务模块，如果需要插入的话，通过类似 service层EventListener监听后， feign接口调用即可
     *
     * @param req
     * @return
     */
    @Operation(summary = "添加-feign接口")
    @PostMapping("/add")
    public Result<Boolean> addLog(@RequestBody OperLogReq req) {
        operLogService.addLog(req);
        return Result.ok();
    }

}
